package com.sasu.university_data.service.impl;

import com.sasu.university_data.entity.AceTeacher;
import com.sasu.university_data.mapper.AceTeacherMapper;
import com.sasu.university_data.service.AceTeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AceTeacher)表服务实现类
 *
 * @author makejava
 * @since 2024-05-04 12:50:32
 */
@Service("aceTeacherService")
public class AceTeacherServiceImpl implements AceTeacherService {
    @Resource
    private AceTeacherMapper aceTeacherMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param atId 主键
     * @return 实例对象
     */
    @Override
    public AceTeacher queryById( Integer atId) {
        return this.aceTeacherMapper.queryById(atId);
    }


    @Override
    public long count (String schoolName) {
        return aceTeacherMapper.count(schoolName);
    }

    @Override
    public List<AceTeacher> selectByPage ( String schoolName, Integer page, Integer pageSize ) {

        if(page<=1) {
            page = 1;
        }
        if(pageSize<=0) {
            pageSize = 10;
        }
        return aceTeacherMapper.selectByPage(schoolName,(page - 1) * pageSize, pageSize);
    }

    /**
     * 新增数据
     *
     * @param aceTeacher 实例对象
     * @return 是否成功
     */
    @Override
    public boolean insert(AceTeacher aceTeacher) {

        return aceTeacherMapper.insert(aceTeacher)>0;
    }

    /**
     * 修改数据
     *
     * @param aceTeacher 实例对象
     * @return 是否成功
     */
    @Override
    public boolean update(AceTeacher aceTeacher) {
        int flag = aceTeacherMapper.update(aceTeacher);
        return flag > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param atId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer atId) {
        return aceTeacherMapper.deleteById(atId) > 0;
    }

    @Override
    public boolean deleteByIds ( int[] ids ) {
        return aceTeacherMapper.deleteByIds(ids)>0;
    }

    //TODO
    @Override
    public List<AceTeacher> queryByiId(Integer atId) {


        return null;
    }
}
